/*   1:    */ package com.sie.driver.ftusbdriver;
/*   2:    */ 
/*   3:    */ class FT_EE_X_Ctrl
/*   4:    */   extends FT_EE_Ctrl
/*   5:    */ {
/*   6:    */   private static final String DEFAULT_PID = "6015";
/*   7:    */   private static final byte UART = 0;
/*   8:    */   private static final byte FIFO = 1;
/*   9:    */   private static final byte FT1248 = 2;
/*  10:    */   private static final byte I2C = 3;
/*  11:    */   private static final int DEVICE_TYPE_EE_LOC = 73;
/*  12:    */   private static final int BCD_ENABLE = 1;
/*  13:    */   private static final int FORCE_POWER_ENABLE = 2;
/*  14:    */   private static final int DEACTIVATE_SLEEP = 4;
/*  15:    */   private static final int RS485_ECHO = 8;
/*  16:    */   private static final int VBUS_SUSPEND = 64;
/*  17:    */   private static final int LOAD_DRIVER = 128;
/*  18:    */   private static final int FT1248_CLK_POLARITY = 16;
/*  19:    */   private static final int FT1248_BIT_ORDER = 32;
/*  20:    */   private static final int FT1248_FLOW_CTRL = 64;
/*  21:    */   private static final int I2C_DISABLE_SCHMITT = 128;
/*  22:    */   private static final int INVERT_TXD = 256;
/*  23:    */   private static final int INVERT_RXD = 512;
/*  24:    */   private static final int INVERT_RTS = 1024;
/*  25:    */   private static final int INVERT_CTS = 2048;
/*  26:    */   private static final int INVERT_DTR = 4096;
/*  27:    */   private static final int INVERT_DSR = 8192;
/*  28:    */   private static final int INVERT_DCD = 16384;
/*  29:    */   private static final int INVERT_RI = 32768;
/*  30:    */   private static final int DBUS_DRIVE = 3;
/*  31:    */   private static final int CBUS_DRIVE = 48;
/*  32:    */   private static final int DBUS_SLEW = 4;
/*  33:    */   private static final int DBUS_SCHMITT = 8;
/*  34:    */   private static final int CBUS_SLEW = 64;
/*  35:    */   private static final int CBUS_SCHMITT = 128;
/*  36:    */   private static FT_Device ft_device;
/*  37:    */   private static final short EE_MAX_SIZE = 1024;
/*  38:    */   
/*  39:    */   FT_EE_X_Ctrl(FT_Device usbC)
/*  40:    */   {
/*  41: 46 */     super(usbC);
/*  42: 47 */     ft_device = usbC;
/*  43: 48 */     this.mEepromSize = 128;
/*  44: 49 */     this.mEepromType = 1;
/*  45:    */   }
/*  46:    */   
/*  47:    */   short programEeprom(FT_EEPROM ee)
/*  48:    */   {
/*  49: 57 */     int[] dataToWrite = new int[this.mEepromSize];
/*  50: 58 */     short counter = 0;
/*  51: 60 */     if (ee.getClass() != FT_EEPROM_X_Series.class) {
/*  52: 61 */       return 1;
/*  53:    */     }
/*  54: 63 */     FT_EEPROM_X_Series eeprom = (FT_EEPROM_X_Series)ee;
/*  55:    */     do
/*  56:    */     {
/*  57: 67 */       dataToWrite[counter] = readWord(counter);
/*  58: 65 */     } while (
/*  59:    */     
/*  60:    */ 
/*  61: 68 */       (counter = (short)(counter + 1)) < this.mEepromSize);
/*  62:    */     try
/*  63:    */     {
/*  64: 75 */       dataToWrite[0] = 0;
/*  65: 76 */       if (eeprom.BCDEnable) {
/*  66: 77 */         dataToWrite[0] |= 0x1;
/*  67:    */       }
/*  68: 78 */       if (eeprom.BCDForceCBusPWREN) {
/*  69: 79 */         dataToWrite[0] |= 0x2;
/*  70:    */       }
/*  71: 80 */       if (eeprom.BCDDisableSleep) {
/*  72: 81 */         dataToWrite[0] |= 0x4;
/*  73:    */       }
/*  74: 82 */       if (eeprom.RS485EchoSuppress) {
/*  75: 83 */         dataToWrite[0] |= 0x8;
/*  76:    */       }
/*  77: 84 */       if (eeprom.A_LoadVCP) {
/*  78: 85 */         dataToWrite[0] |= 0x80;
/*  79:    */       }
/*  80: 86 */       if (eeprom.PowerSaveEnable)
/*  81:    */       {
/*  82: 90 */         boolean found = false;
/*  83: 91 */         if (eeprom.CBus0 == 17) {
/*  84: 92 */           found = true;
/*  85:    */         }
/*  86: 93 */         if (eeprom.CBus1 == 17) {
/*  87: 94 */           found = true;
/*  88:    */         }
/*  89: 95 */         if (eeprom.CBus2 == 17) {
/*  90: 96 */           found = true;
/*  91:    */         }
/*  92: 97 */         if (eeprom.CBus3 == 17) {
/*  93: 98 */           found = true;
/*  94:    */         }
/*  95: 99 */         if (eeprom.CBus4 == 17) {
/*  96:100 */           found = true;
/*  97:    */         }
/*  98:101 */         if (eeprom.CBus5 == 17) {
/*  99:102 */           found = true;
/* 100:    */         }
/* 101:103 */         if (eeprom.CBus6 == 17) {
/* 102:104 */           found = true;
/* 103:    */         }
/* 104:106 */         if (found) {
/* 105:107 */           dataToWrite[0] |= 0x40;
/* 106:    */         } else {
/* 107:109 */           return 1;
/* 108:    */         }
/* 109:    */       }
/* 110:115 */       dataToWrite[1] = eeprom.VendorId;
/* 111:    */       
/* 112:    */ 
/* 113:    */ 
/* 114:    */ 
/* 115:120 */       dataToWrite[2] = eeprom.ProductId;
/* 116:    */       
/* 117:    */ 
/* 118:    */ 
/* 119:    */ 
/* 120:125 */       dataToWrite[3] = 4096;
/* 121:    */       
/* 122:    */ 
/* 123:    */ 
/* 124:    */ 
/* 125:130 */       dataToWrite[4] = setUSBConfig(ee);
/* 126:    */       
/* 127:    */ 
/* 128:    */ 
/* 129:    */ 
/* 130:135 */       dataToWrite[5] = setDeviceControl(ee);
/* 131:137 */       if (eeprom.FT1248ClockPolarity) {
/* 132:138 */         dataToWrite[5] |= 0x10;
/* 133:    */       }
/* 134:139 */       if (eeprom.FT1248LSB) {
/* 135:140 */         dataToWrite[5] |= 0x20;
/* 136:    */       }
/* 137:141 */       if (eeprom.FT1248FlowControl) {
/* 138:142 */         dataToWrite[5] |= 0x40;
/* 139:    */       }
/* 140:143 */       if (eeprom.I2CDisableSchmitt) {
/* 141:144 */         dataToWrite[5] |= 0x80;
/* 142:    */       }
/* 143:146 */       if (eeprom.InvertTXD) {
/* 144:147 */         dataToWrite[5] |= 0x100;
/* 145:    */       }
/* 146:148 */       if (eeprom.InvertRXD) {
/* 147:149 */         dataToWrite[5] |= 0x200;
/* 148:    */       }
/* 149:150 */       if (eeprom.InvertRTS) {
/* 150:151 */         dataToWrite[5] |= 0x400;
/* 151:    */       }
/* 152:152 */       if (eeprom.InvertCTS) {
/* 153:153 */         dataToWrite[5] |= 0x800;
/* 154:    */       }
/* 155:154 */       if (eeprom.InvertDTR) {
/* 156:155 */         dataToWrite[5] |= 0x1000;
/* 157:    */       }
/* 158:156 */       if (eeprom.InvertDSR) {
/* 159:157 */         dataToWrite[5] |= 0x2000;
/* 160:    */       }
/* 161:158 */       if (eeprom.InvertDCD) {
/* 162:159 */         dataToWrite[5] |= 0x4000;
/* 163:    */       }
/* 164:160 */       if (eeprom.InvertRI) {
/* 165:161 */         dataToWrite[5] |= 0x8000;
/* 166:    */       }
/* 167:166 */       dataToWrite[6] = 0;
/* 168:167 */       short driveA = eeprom.AD_DriveCurrent;
/* 169:168 */       if (driveA == -1) {
/* 170:168 */         driveA = 0;
/* 171:    */       }
/* 172:169 */       dataToWrite[6] |= driveA;
/* 173:170 */       if (eeprom.AD_SlowSlew) {
/* 174:171 */         dataToWrite[6] |= 0x4;
/* 175:    */       }
/* 176:172 */       if (eeprom.AD_SchmittInput) {
/* 177:173 */         dataToWrite[6] |= 0x8;
/* 178:    */       }
/* 179:175 */       short driveC = eeprom.AC_DriveCurrent;
/* 180:176 */       if (driveC == -1) {
/* 181:176 */         driveC = 0;
/* 182:    */       }
/* 183:177 */       driveC = (short)(driveC << 4);
/* 184:178 */       dataToWrite[6] |= driveC;
/* 185:179 */       if (eeprom.AC_SlowSlew) {
/* 186:180 */         dataToWrite[6] |= 0x40;
/* 187:    */       }
/* 188:181 */       if (eeprom.AC_SchmittInput) {
/* 189:182 */         dataToWrite[6] |= 0x80;
/* 190:    */       }
/* 191:192 */       int offset = 80;
/* 192:193 */       offset = setStringDescriptor(eeprom.Manufacturer, dataToWrite, offset, 7, false);
/* 193:    */       
/* 194:    */ 
/* 195:    */ 
/* 196:    */ 
/* 197:198 */       offset = setStringDescriptor(eeprom.Product, dataToWrite, offset, 8, false);
/* 198:203 */       if (eeprom.SerNumEnable) {
/* 199:204 */         offset = setStringDescriptor(eeprom.SerialNumber, dataToWrite, offset, 9, false);
/* 200:    */       }
/* 201:209 */       dataToWrite[10] = eeprom.I2CSlaveAddress;
/* 202:    */       
/* 203:    */ 
/* 204:    */ 
/* 205:213 */       dataToWrite[11] = (eeprom.I2CDeviceID & 0xFFFF);
/* 206:    */       
/* 207:    */ 
/* 208:    */ 
/* 209:217 */       dataToWrite[12] = (eeprom.I2CDeviceID >> 16);
/* 210:    */       
/* 211:    */ 
/* 212:    */ 
/* 213:    */ 
/* 214:222 */       int c0 = eeprom.CBus0;
/* 215:223 */       if (c0 == -1) {
/* 216:224 */         c0 = 0;
/* 217:    */       }
/* 218:225 */       int c1 = eeprom.CBus1;
/* 219:226 */       if (c1 == -1) {
/* 220:227 */         c1 = 0;
/* 221:    */       }
/* 222:228 */       c1 <<= 8;
/* 223:    */       
/* 224:230 */       dataToWrite[13] = ((short)(c0 | c1));
/* 225:    */       
/* 226:    */ 
/* 227:    */ 
/* 228:234 */       int c2 = eeprom.CBus2;
/* 229:235 */       if (c2 == -1) {
/* 230:235 */         c2 = 0;
/* 231:    */       }
/* 232:236 */       int c3 = eeprom.CBus3;
/* 233:237 */       if (c3 == -1) {
/* 234:237 */         c3 = 0;
/* 235:    */       }
/* 236:238 */       c3 <<= 8;
/* 237:    */       
/* 238:240 */       dataToWrite[14] = ((short)(c2 | c3));
/* 239:    */       
/* 240:    */ 
/* 241:    */ 
/* 242:244 */       int c4 = eeprom.CBus4;
/* 243:245 */       if (c4 == -1) {
/* 244:246 */         c4 = 0;
/* 245:    */       }
/* 246:247 */       int c5 = eeprom.CBus5;
/* 247:248 */       if (c5 == -1) {
/* 248:249 */         c5 = 0;
/* 249:    */       }
/* 250:250 */       c5 <<= 8;
/* 251:    */       
/* 252:252 */       dataToWrite[15] = ((short)(c4 | c5));
/* 253:    */       
/* 254:    */ 
/* 255:    */ 
/* 256:    */ 
/* 257:257 */       int c6 = eeprom.CBus6;
/* 258:258 */       if (c6 == -1) {
/* 259:259 */         c6 = 0;
/* 260:    */       }
/* 261:261 */       dataToWrite[16] = ((short)c6);
/* 262:266 */       if ((dataToWrite[1] != 0) && (dataToWrite[2] != 0))
/* 263:    */       {
/* 264:268 */         boolean returnCode = false;
/* 265:269 */         returnCode = programXeeprom(dataToWrite, this.mEepromSize - 1);
/* 266:271 */         if (returnCode) {
/* 267:272 */           return 0;
/* 268:    */         }
/* 269:274 */         return 1;
/* 270:    */       }
/* 271:278 */       return 2;
/* 272:    */     }
/* 273:    */     catch (Exception e)
/* 274:    */     {
/* 275:283 */       e.printStackTrace();
/* 276:    */     }
/* 277:285 */     return 0;
/* 278:    */   }
/* 279:    */   
/* 280:    */   boolean programXeeprom(int[] dataToWrite, int ee_size)
/* 281:    */   {
/* 282:290 */     int checksumLocation = ee_size;
/* 283:    */     
/* 284:292 */     int Checksum = 43690;
/* 285:293 */     int TempChecksum = 0;
/* 286:294 */     int addressCounter = 0;
/* 287:295 */     int a = 0;int b = 0;
/* 288:296 */     int data = 0;
/* 289:    */     do
/* 290:    */     {
/* 291:300 */       data = dataToWrite[addressCounter];
/* 292:301 */       data &= 0xFFFF;
/* 293:302 */       writeWord((short)addressCounter, (short)data);
/* 294:    */       
/* 295:    */ 
/* 296:305 */       TempChecksum = data ^ Checksum;
/* 297:306 */       TempChecksum &= 0xFFFF;
/* 298:    */       
/* 299:308 */       a = TempChecksum << 1;
/* 300:309 */       a &= 0xFFFF;
/* 301:311 */       if ((TempChecksum & 0x8000) > 0) {
/* 302:312 */         b = 1;
/* 303:    */       } else {
/* 304:314 */         b = 0;
/* 305:    */       }
/* 306:316 */       Checksum = a | b;
/* 307:317 */       Checksum &= 0xFFFF;
/* 308:318 */       addressCounter++;
/* 309:320 */       if (addressCounter == 18) {
/* 310:321 */         addressCounter = 64;
/* 311:    */       }
/* 312:323 */     } while (addressCounter != checksumLocation);
/* 313:324 */     writeWord((short)checksumLocation, (short)Checksum);
/* 314:    */     
/* 315:    */ 
/* 316:    */ 
/* 317:    */ 
/* 318:329 */     return true;
/* 319:    */   }
/* 320:    */   
/* 321:    */   FT_EEPROM readEeprom()
/* 322:    */   {
/* 323:335 */     FT_EEPROM_X_Series eeprom = new FT_EEPROM_X_Series();
/* 324:336 */     int[] dataRead = new int[this.mEepromSize];
/* 325:    */     try
/* 326:    */     {
/* 327:340 */       for (short i = 0; i < this.mEepromSize; i = (short)(i + 1)) {
/* 328:341 */         dataRead[i] = readWord(i);
/* 329:    */       }
/* 330:347 */       if ((dataRead[0] & 0x1) > 0) {
/* 331:348 */         eeprom.BCDEnable = true;
/* 332:    */       } else {
/* 333:350 */         eeprom.BCDEnable = false;
/* 334:    */       }
/* 335:351 */       if ((dataRead[0] & 0x2) > 0) {
/* 336:352 */         eeprom.BCDForceCBusPWREN = true;
/* 337:    */       } else {
/* 338:354 */         eeprom.BCDForceCBusPWREN = false;
/* 339:    */       }
/* 340:356 */       if ((dataRead[0] & 0x4) > 0) {
/* 341:357 */         eeprom.BCDDisableSleep = true;
/* 342:    */       } else {
/* 343:359 */         eeprom.BCDDisableSleep = false;
/* 344:    */       }
/* 345:361 */       if ((dataRead[0] & 0x8) > 0) {
/* 346:362 */         eeprom.RS485EchoSuppress = true;
/* 347:    */       } else {
/* 348:364 */         eeprom.RS485EchoSuppress = false;
/* 349:    */       }
/* 350:366 */       if ((dataRead[0] & 0x40) > 0) {
/* 351:367 */         eeprom.PowerSaveEnable = true;
/* 352:    */       } else {
/* 353:369 */         eeprom.PowerSaveEnable = false;
/* 354:    */       }
/* 355:370 */       if ((dataRead[0] & 0x80) > 0)
/* 356:    */       {
/* 357:372 */         eeprom.A_LoadVCP = true;
/* 358:373 */         eeprom.A_LoadD2XX = false;
/* 359:    */       }
/* 360:    */       else
/* 361:    */       {
/* 362:377 */         eeprom.A_LoadVCP = false;
/* 363:378 */         eeprom.A_LoadD2XX = true;
/* 364:    */       }
/* 365:384 */       eeprom.VendorId = ((short)dataRead[1]);
/* 366:    */       
/* 367:    */ 
/* 368:    */ 
/* 369:    */ 
/* 370:389 */       eeprom.ProductId = ((short)dataRead[2]);
/* 371:    */       
/* 372:    */ 
/* 373:    */ 
/* 374:    */ 
/* 375:    */ 
/* 376:    */ 
/* 377:    */ 
/* 378:    */ 
/* 379:    */ 
/* 380:    */ 
/* 381:400 */       getUSBConfig(eeprom, dataRead[4]);
/* 382:    */       
/* 383:    */ 
/* 384:    */ 
/* 385:    */ 
/* 386:405 */       getDeviceControl(eeprom, dataRead[5]);
/* 387:408 */       if ((dataRead[5] & 0x10) > 0) {
/* 388:409 */         eeprom.FT1248ClockPolarity = true;
/* 389:    */       } else {
/* 390:411 */         eeprom.FT1248ClockPolarity = false;
/* 391:    */       }
/* 392:413 */       if ((dataRead[5] & 0x20) > 0) {
/* 393:414 */         eeprom.FT1248LSB = true;
/* 394:    */       } else {
/* 395:416 */         eeprom.FT1248LSB = false;
/* 396:    */       }
/* 397:418 */       if ((dataRead[5] & 0x40) > 0) {
/* 398:419 */         eeprom.FT1248FlowControl = true;
/* 399:    */       } else {
/* 400:421 */         eeprom.FT1248FlowControl = false;
/* 401:    */       }
/* 402:424 */       if ((dataRead[5] & 0x80) > 0) {
/* 403:425 */         eeprom.I2CDisableSchmitt = true;
/* 404:    */       } else {
/* 405:427 */         eeprom.I2CDisableSchmitt = false;
/* 406:    */       }
/* 407:430 */       if ((dataRead[5] & 0x100) == 256) {
/* 408:431 */         eeprom.InvertTXD = true;
/* 409:    */       } else {
/* 410:433 */         eeprom.InvertTXD = false;
/* 411:    */       }
/* 412:436 */       if ((dataRead[5] & 0x200) == 512) {
/* 413:437 */         eeprom.InvertRXD = true;
/* 414:    */       } else {
/* 415:439 */         eeprom.InvertRXD = false;
/* 416:    */       }
/* 417:442 */       if ((dataRead[5] & 0x400) == 1024) {
/* 418:443 */         eeprom.InvertRTS = true;
/* 419:    */       } else {
/* 420:445 */         eeprom.InvertRTS = false;
/* 421:    */       }
/* 422:448 */       if ((dataRead[5] & 0x800) == 2048) {
/* 423:449 */         eeprom.InvertCTS = true;
/* 424:    */       } else {
/* 425:451 */         eeprom.InvertCTS = false;
/* 426:    */       }
/* 427:454 */       if ((dataRead[5] & 0x1000) == 4096) {
/* 428:455 */         eeprom.InvertDTR = true;
/* 429:    */       } else {
/* 430:457 */         eeprom.InvertDTR = false;
/* 431:    */       }
/* 432:460 */       if ((dataRead[5] & 0x2000) == 8192) {
/* 433:461 */         eeprom.InvertDSR = true;
/* 434:    */       } else {
/* 435:463 */         eeprom.InvertDSR = false;
/* 436:    */       }
/* 437:466 */       if ((dataRead[5] & 0x4000) == 16384) {
/* 438:467 */         eeprom.InvertDCD = true;
/* 439:    */       } else {
/* 440:469 */         eeprom.InvertDCD = false;
/* 441:    */       }
/* 442:472 */       if ((dataRead[5] & 0x8000) == 32768) {
/* 443:473 */         eeprom.InvertRI = true;
/* 444:    */       } else {
/* 445:475 */         eeprom.InvertRI = false;
/* 446:    */       }
/* 447:481 */       short data01x06 = (short)(dataRead[6] & 0x3);
/* 448:483 */       switch (data01x06)
/* 449:    */       {
/* 450:    */       case 0: 
/* 451:485 */         eeprom.AD_DriveCurrent = 0;
/* 452:486 */         break;
/* 453:    */       case 1: 
/* 454:488 */         eeprom.AD_DriveCurrent = 1;
/* 455:489 */         break;
/* 456:    */       case 2: 
/* 457:491 */         eeprom.AD_DriveCurrent = 2;
/* 458:492 */         break;
/* 459:    */       case 3: 
/* 460:494 */         eeprom.AD_DriveCurrent = 3;
/* 461:495 */         break;
/* 462:    */       }
/* 463:500 */       short data2x06 = (short)(dataRead[6] & 0x4);
/* 464:501 */       if (data2x06 == 4) {
/* 465:502 */         eeprom.AD_SlowSlew = true;
/* 466:    */       } else {
/* 467:505 */         eeprom.AD_SlowSlew = false;
/* 468:    */       }
/* 469:508 */       short data3x06 = (short)(dataRead[6] & 0x8);
/* 470:509 */       if (data3x06 == 8) {
/* 471:510 */         eeprom.AD_SchmittInput = true;
/* 472:    */       } else {
/* 473:512 */         eeprom.AD_SchmittInput = false;
/* 474:    */       }
/* 475:515 */       short data45x06 = (short)((dataRead[6] & 0x30) >> 4);
/* 476:517 */       switch (data45x06)
/* 477:    */       {
/* 478:    */       case 0: 
/* 479:519 */         eeprom.AC_DriveCurrent = 0;
/* 480:520 */         break;
/* 481:    */       case 1: 
/* 482:522 */         eeprom.AC_DriveCurrent = 1;
/* 483:523 */         break;
/* 484:    */       case 2: 
/* 485:525 */         eeprom.AC_DriveCurrent = 2;
/* 486:526 */         break;
/* 487:    */       case 3: 
/* 488:528 */         eeprom.AC_DriveCurrent = 3;
/* 489:529 */         break;
/* 490:    */       }
/* 491:534 */       short data6x06 = (short)(dataRead[6] & 0x40);
/* 492:535 */       if (data6x06 == 64) {
/* 493:536 */         eeprom.AC_SlowSlew = true;
/* 494:    */       } else {
/* 495:539 */         eeprom.AC_SlowSlew = false;
/* 496:    */       }
/* 497:542 */       short data7x06 = (short)(dataRead[6] & 0x80);
/* 498:543 */       if (data7x06 == 128) {
/* 499:544 */         eeprom.AC_SchmittInput = true;
/* 500:    */       } else {
/* 501:546 */         eeprom.AC_SchmittInput = false;
/* 502:    */       }
/* 503:551 */       eeprom.I2CSlaveAddress = dataRead[10];
/* 504:    */       
/* 505:    */ 
/* 506:    */ 
/* 507:    */ 
/* 508:556 */       eeprom.I2CDeviceID = dataRead[11];
/* 509:    */       
/* 510:    */ 
/* 511:    */ 
/* 512:    */ 
/* 513:561 */       eeprom.I2CDeviceID |= (dataRead[12] & 0xFF) << 16;
/* 514:    */       
/* 515:    */ 
/* 516:    */ 
/* 517:    */ 
/* 518:566 */       eeprom.CBus0 = ((byte)(dataRead[13] & 0xFF));
/* 519:567 */       eeprom.CBus1 = ((byte)(dataRead[13] >> 8 & 0xFF));
/* 520:    */       
/* 521:    */ 
/* 522:    */ 
/* 523:    */ 
/* 524:572 */       eeprom.CBus2 = ((byte)(dataRead[14] & 0xFF));
/* 525:573 */       eeprom.CBus3 = ((byte)(dataRead[14] >> 8 & 0xFF));
/* 526:    */       
/* 527:    */ 
/* 528:    */ 
/* 529:    */ 
/* 530:578 */       eeprom.CBus4 = ((byte)(dataRead[15] & 0xFF));
/* 531:579 */       eeprom.CBus5 = ((byte)(dataRead[15] >> 8 & 0xFF));
/* 532:    */       
/* 533:    */ 
/* 534:    */ 
/* 535:    */ 
/* 536:584 */       eeprom.CBus6 = ((byte)(dataRead[16] & 0xFF));
/* 537:    */       
/* 538:    */ 
/* 539:    */ 
/* 540:588 */       this.mEepromType = ((short)(dataRead[73] >> 8));
/* 541:    */       
/* 542:    */ 
/* 543:    */ 
/* 544:    */ 
/* 545:593 */       int addr = dataRead[7] & 0xFF;
/* 546:594 */       addr /= 2;
/* 547:595 */       eeprom.Manufacturer = getStringDescriptor(addr, dataRead);
/* 548:596 */       addr = dataRead[8] & 0xFF;
/* 549:597 */       addr /= 2;
/* 550:598 */       eeprom.Product = getStringDescriptor(addr, dataRead);
/* 551:599 */       addr = dataRead[9] & 0xFF;
/* 552:600 */       addr /= 2;
/* 553:601 */       eeprom.SerialNumber = getStringDescriptor(addr, dataRead);
/* 554:    */       
/* 555:603 */       return eeprom;
/* 556:    */     }
/* 557:    */     catch (Exception e) {}
/* 558:607 */     return null;
/* 559:    */   }
/* 560:    */   
/* 561:    */   int getUserSize()
/* 562:    */   {
/* 563:616 */     int data = readWord((short)9);
/* 564:617 */     int ptr = data & 0xFF;
/* 565:618 */     ptr /= 2;
/* 566:    */     
/* 567:    */ 
/* 568:621 */     int length = (data & 0xFF00) >> 8;
/* 569:622 */     ptr += length / 2;
/* 570:623 */     ptr++;
/* 571:    */     
/* 572:625 */     return (this.mEepromSize - 1 - 1 - ptr) * 2;
/* 573:    */   }
/* 574:    */   
/* 575:    */   int writeUserData(byte[] data)
/* 576:    */   {
/* 577:632 */     int dataWrite = 0;
/* 578:633 */     short offset = 0;
/* 579:635 */     if (data.length > getUserSize()) {
/* 580:636 */       return 0;
/* 581:    */     }
/* 582:638 */     int[] eeprom = new int[this.mEepromSize];
/* 583:639 */     for (short i = 0; i < this.mEepromSize; i = (short)(i + 1)) {
/* 584:640 */       eeprom[i] = readWord(i);
/* 585:    */     }
/* 586:643 */     offset = (short)(this.mEepromSize - getUserSize() / 2 - 1 - 1);
/* 587:645 */     for (int i = 0; i < data.length; i += 2)
/* 588:    */     {
/* 589:647 */       if (i + 1 < data.length) {
/* 590:648 */         dataWrite = data[(i + 1)] & 0xFF;
/* 591:    */       } else {
/* 592:650 */         dataWrite = 0;
/* 593:    */       }
/* 594:652 */       dataWrite <<= 8;
/* 595:653 */       dataWrite |= data[i] & 0xFF;
/* 596:    */       
/* 597:655 */       eeprom[(offset++)] = dataWrite;
/* 598:    */     }
/* 599:659 */     if ((eeprom[1] != 0) && (eeprom[2] != 0))
/* 600:    */     {
/* 601:661 */       boolean returnCode = false;
/* 602:662 */       returnCode = programXeeprom(eeprom, this.mEepromSize - 1);
/* 603:663 */       if (!returnCode) {
/* 604:664 */         return 0;
/* 605:    */       }
/* 606:    */     }
/* 607:    */     else
/* 608:    */     {
/* 609:668 */       return 0;
/* 610:    */     }
/* 611:671 */     return data.length;
/* 612:    */   }
/* 613:    */   
/* 614:    */   byte[] readUserData(int length)
/* 615:    */   {
/* 616:677 */     byte Hi = 0;
/* 617:678 */     byte Lo = 0;
/* 618:679 */     int dataRead = 0;
/* 619:680 */     byte[] data = new byte[length];
/* 620:682 */     if ((length == 0) || (length > getUserSize())) {
/* 621:683 */       return null;
/* 622:    */     }
/* 623:685 */     short offset = (short)(this.mEepromSize - getUserSize() / 2 - 1 - 1);
/* 624:687 */     for (int i = 0; i < length; i += 2)
/* 625:    */     {
/* 626:689 */       dataRead = readWord(offset++);
/* 627:691 */       if (i + 1 < data.length)
/* 628:    */       {
/* 629:693 */         Hi = (byte)(dataRead & 0xFF);
/* 630:694 */         data[(i + 1)] = Hi;
/* 631:    */       }
/* 632:    */       else
/* 633:    */       {
/* 634:698 */         Lo = 0;
/* 635:    */       }
/* 636:700 */       Lo = (byte)((dataRead & 0xFF00) >> 8);
/* 637:701 */       data[i] = Lo;
/* 638:    */     }
/* 639:703 */     return data;
/* 640:    */   }
/* 641:    */ }



/* Location:           E:\code\demo\A108DevForBankComm\libs\d2xx.jar

 * Qualified Name:     com.ftdi.j2xx.FT_EE_X_Ctrl

 * JD-Core Version:    0.7.0.1

 */